/*
 * Generated file. 
 * 
 * MainTopic.java
 */
package xsp;

import com.ibm.xsp.page.compiled.AbstractCompiledPage;
import com.ibm.xsp.page.compiled.AbstractCompiledPageDispatcher;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.ibm.xsp.page.compiled.NoSuchComponentException;
import com.ibm.xsp.page.compiled.PageExpressionEvaluator;
import java.lang.String;
import com.ibm.xsp.component.FacesPageProvider;
import com.ibm.xsp.model.domino.DominoDocumentData;
import javax.faces.el.MethodBinding;
import com.ibm.xsp.component.FacesDataProvider;
import com.ibm.xsp.component.UIViewRootEx2;
import java.lang.Boolean;
import com.ibm.xsp.extlib.component.mobile.UIDMHeading;
import javax.faces.el.ValueBinding;
import com.ibm.xsp.extlib.component.data.UIFormTable;
import com.ibm.xsp.extlib.component.data.UIFormLayoutRow;
import com.ibm.xsp.component.xp.XspInputText;
import java.lang.Object;
import com.ibm.xsp.component.xp.XspTypeAhead;
import com.ibm.xsp.component.xp.XspInputRichText;
import com.ibm.xsp.component.UIPanelEx;
import com.ibm.xsp.component.xp.XspOutputLink;
import com.ibm.xsp.component.xp.XspEventHandler;
import com.ibm.xsp.component.xp.XspGraphicImage;
import com.ibm.xsp.component.xp.XspDiv;
import com.ibm.xsp.component.xp.XspFileDownload;
import com.ibm.xsp.component.xp.XspLineBreak;
import com.ibm.xsp.component.xp.XspFileUpload;
import com.ibm.xsp.component.xp.XspCommandButton;
import com.ibm.xsp.actions.ActionGroup;
import com.ibm.xsp.actions.SaveAction;
import java.util.Map;

@SuppressWarnings("all")
public class MainTopic extends AbstractCompiledPageDispatcher{
    
    public MainTopic() {
        super("8.5.2"); // version of xp:link role
    }

    protected AbstractCompiledPage createPage(int pageIndex) {
        return new MainTopicPage();
    }
    
    protected boolean isCustomControl() {
        return true;
    }

    public static class MainTopicPage extends AbstractCompiledPage {
        
        private static final ComponentInfo[] s_infos = new ComponentInfo[]{
            ComponentInfo.EMPTY_NORMAL, // 0 "djxmheading1"
            ComponentInfo.EMPTY_NORMAL, // 1 "inputtext1"
            new ComponentInfo(false, new int[]{1}), // 2 "formrow1"
            ComponentInfo.EMPTY_NORMAL, // 3 "typeahead1"
            new ComponentInfo(false, new int[]{3}), // 4 "inputtext2"
            new ComponentInfo(false, new int[]{4}), // 5 "formrow2"
            ComponentInfo.EMPTY_NORMAL, // 6 "rtbody"
            new ComponentInfo(false, new int[]{6}), // 7 "formrow3"
            new ComponentInfo(false, new int[]{2, 5, 7}), // 8 "formtable2"
            ComponentInfo.EMPTY_NORMAL, // 9 "eventhandler4"
            ComponentInfo.EMPTY_NORMAL, // 10 "image2"
            new ComponentInfo(false, new int[]{9, 10}), // 11 "link1"
            ComponentInfo.EMPTY_NORMAL, // 12 "filedownload1"
            new ComponentInfo(false, new int[]{12}), // 13 div
            new ComponentInfo(false, new int[]{11, 13}), // 14 "panel1"
            ComponentInfo.EMPTY_NORMAL, // 15 br
            ComponentInfo.EMPTY_NORMAL, // 16 eventHandler
            new ComponentInfo(false, new int[]{16}), // 17 "fileupload"
            new ComponentInfo(false, new int[]{15, 17}), // 18 "filecontainer"
            ComponentInfo.EMPTY_NORMAL, // 19 br2
            ComponentInfo.EMPTY_NORMAL, // 20 br3
            ComponentInfo.EMPTY_NORMAL, // 21 "eventhandler2"
            new ComponentInfo(false, new int[]{21}), // 22 "button2"
            ComponentInfo.EMPTY_NORMAL, // 23 "linkcancel"
            new ComponentInfo(false, new int[]{22, 23}), // 24 "panel16"
            new ComponentInfo(false, new int[]{0, 8, 14, 18, 19, 20, 24}), // 25 view
        };
        
        public MainTopicPage() {
            super(25, s_infos );
        }
        
        public int getComponentForId(String id) throws NoSuchComponentException { 
            if( "djxmheading1".equals(id) )
                return 0;
            if( "formtable2".equals(id) )
                return 8;
            if( "formrow1".equals(id) )
                return 2;
            if( "inputtext1".equals(id) )
                return 1;
            if( "formrow2".equals(id) )
                return 5;
            if( "inputtext2".equals(id) )
                return 4;
            if( "typeahead1".equals(id) )
                return 3;
            if( "formrow3".equals(id) )
                return 7;
            if( "rtbody".equals(id) )
                return 6;
            if( "panel1".equals(id) )
                return 14;
            if( "link1".equals(id) )
                return 11;
            if( "eventhandler4".equals(id) )
                return 9;
            if( "image2".equals(id) )
                return 10;
            if( "filedownload1".equals(id) )
                return 12;
            if( "filecontainer".equals(id) )
                return 18;
            if( "fileupload".equals(id) )
                return 17;
            if( "panel16".equals(id) )
                return 24;
            if( "button2".equals(id) )
                return 22;
            if( "eventhandler2".equals(id) )
                return 21;
            if( "linkcancel".equals(id) )
                return 23;
            return -1;
        }
        
        public UIComponent createComponent(int id, FacesContext context,
                UIComponent parent, PageExpressionEvaluator evaluator)
                throws NoSuchComponentException { 
            switch (id) {
            case 25:
                return createView(context, parent, evaluator);
            case 0:
                return createDjxmheading1(context, parent, evaluator);
            case 8:
                return createFormtable2(context, parent, evaluator);
            case 2:
                return createFormrow1(context, parent, evaluator);
            case 1:
                return createInputtext1(context, parent, evaluator);
            case 5:
                return createFormrow2(context, parent, evaluator);
            case 4:
                return createInputtext2(context, parent, evaluator);
            case 3:
                return createTypeahead1(context, parent, evaluator);
            case 7:
                return createFormrow3(context, parent, evaluator);
            case 6:
                return createRtbody(context, parent, evaluator);
            case 14:
                return createPanel1(context, parent, evaluator);
            case 11:
                return createLink1(context, parent, evaluator);
            case 9:
                return createEventhandler4(context, parent, evaluator);
            case 10:
                return createImage2(context, parent, evaluator);
            case 13:
                return createDiv(context, parent, evaluator);
            case 12:
                return createFiledownload1(context, parent, evaluator);
            case 18:
                return createFilecontainer(context, parent, evaluator);
            case 15:
                return createBr(context, parent, evaluator);
            case 17:
                return createFileupload(context, parent, evaluator);
            case 16:
                return createEventHandler(context, parent, evaluator);
            case 19:
                return createBr2(context, parent, evaluator);
            case 20:
                return createBr3(context, parent, evaluator);
            case 24:
                return createPanel16(context, parent, evaluator);
            case 22:
                return createButton2(context, parent, evaluator);
            case 21:
                return createEventhandler2(context, parent, evaluator);
            case 23:
                return createLinkcancel(context, parent, evaluator);
            }
            throw new NoSuchComponentException(id);
        }
        
        protected void initIncluderAsRoot(FacesContext context,
                PageExpressionEvaluator evaluator, UIComponent root) {
            FacesPageProvider asPageProvider = root instanceof FacesPageProvider ?
                    (FacesPageProvider) root : null;
            if( null != asPageProvider ){
                asPageProvider.setEnableModifiedFlag(true);
            }
            DominoDocumentData data = new DominoDocumentData();
            data.setComponent(root);
            String sourceId = "/xp:view[1]/xp:this.data[1]/xp:dominoDocument[1]/xp:this.querySaveDocument[1]/text()";
            MethodBinding querySaveDocument = evaluator.createMethodBinding(root,
                    "#{javascript:// store user CGI variables\nvar cgi = new CGIVariables();\ndominoDoc.replaceItemValue(\"Remote_User\", cgi.get(\"REMOTE_USER\"));\ndominoDoc.replaceItemValue(\"Remote_Addr\", cgi.get(\"REMOTE_ADDR\"));\ncgi = null;}",
                    null,null, sourceId);
            data.setQuerySaveDocument(querySaveDocument);
            data.setComputeWithForm("onsave");
            data.setAction("newDocument");
            data.setVar("dominoDoc");
            data.setFormName("MainTopic");
            FacesDataProvider asDataProvider = root instanceof FacesDataProvider ?
                    (FacesDataProvider) root : null;
            if( null != asDataProvider ){
                asDataProvider.addData(data);
            }
        }

        private UIComponent createView(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIViewRootEx2 result = new UIViewRootEx2();
            initViewRoot(result);
            result.setEnableModifiedFlag(true);
            DominoDocumentData data = new DominoDocumentData();
            data.setComponent(result);
            String sourceId = "/xp:view[1]/xp:this.data[1]/xp:dominoDocument[1]/xp:this.querySaveDocument[1]/text()";
            MethodBinding querySaveDocument = evaluator.createMethodBinding(result,
                    "#{javascript:// store user CGI variables\nvar cgi = new CGIVariables();\ndominoDoc.replaceItemValue(\"Remote_User\", cgi.get(\"REMOTE_USER\"));\ndominoDoc.replaceItemValue(\"Remote_Addr\", cgi.get(\"REMOTE_ADDR\"));\ncgi = null;}",
                    null,null, sourceId);
            data.setQuerySaveDocument(querySaveDocument);
            data.setComputeWithForm("onsave");
            data.setAction("newDocument");
            data.setVar("dominoDoc");
            data.setFormName("MainTopic");
            result.addData(data);
            return result;
        }

        private UIComponent createDjxmheading1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            // loaded=??
            String loadedBnd = "#{javascript:isMobile()}";
            String sourceId = "djxmHeading1/@loaded";
            String loaded = evaluator.evaluateAsString(null, loadedBnd, sourceId, boolean.class);
            if ( null != loaded && loaded.length() > 0 &&
                    ! Boolean.parseBoolean(loaded) ) {
                return null;
            } // else loaded was true
            UIDMHeading result = new UIDMHeading();
            result.setLabel("All Documents");
            result.setBack("Back");
            setId(result, "djxmHeading1");
            String sourceId2 = "djxmHeading1/xp:this.moveTo[1]/text()";
            String moveToExpr = "#{javascript:\n\t\t\t\tif(null == sessionScope.from)\n\t\t\t\t\treturn \"allDocs\";\n\t\t\t\telse\t\n\t\t\t\t\treturn sessionScope.from;\n\t\t\t}";
            ValueBinding moveTo = evaluator.createValueBinding(result, moveToExpr, sourceId2,String.class);
            result.setValueBinding("moveTo", moveTo);
            return result;
        }

        private UIComponent createFormtable2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIFormTable result = new UIFormTable();
            result.setFormTitle("New Topic");
            setId(result, "formTable2");
            return result;
        }

        private UIComponent createFormrow1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIFormLayoutRow result = new UIFormLayoutRow();
            result.setLabel("Subject:");
            setId(result, "formRow1");
            result.setLabelPosition("left");
            return result;
        }

        private UIComponent createInputtext1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspInputText result = new XspInputText();
            String sourceId = "inputText1/@value";
            String valueExpr = "#{dominoDoc.Subject}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            result.setDisableClientSideValidation(true);
            result.setStyleClass("mblFormRowInput");
            setId(result, "inputText1");
            result.setRequired(true);
            return result;
        }

        private UIComponent createFormrow2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIFormLayoutRow result = new UIFormLayoutRow();
            result.setLabel("Tags:");
            setId(result, "formRow2");
            result.setLabelPosition("left");
            return result;
        }

        private UIComponent createInputtext2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspInputText result = new XspInputText();
            String sourceId = "inputText2/@value";
            String valueExpr = "#{dominoDoc.WebCategories}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            result.setMultipleSeparator(",");
            result.setStyleClass("mblFormRowInput");
            setId(result, "inputText2");
            return result;
        }

        private UIComponent createTypeahead1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspTypeAhead result = new XspTypeAhead();
            result.setIgnoreCase(true);
            result.setMode("partial");
            result.setValueListSeparator(",");
            result.setTokens(",");
            result.setMinChars(1);
            setId(result, "typeAhead1");
            String sourceId = "typeAhead1/xp:this.valueList[1]/text()";
            String valueListExpr = "#{javascript:@DbColumn(@DbName(), \"xpCategoryCloud\", 1)}";
            ValueBinding valueList = evaluator.createValueBinding(result, valueListExpr, sourceId,Object.class);
            result.setValueBinding("valueList", valueList);
            return result;
        }

        private UIComponent createFormrow3(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIFormLayoutRow result = new UIFormLayoutRow();
            setId(result, "formRow3");
            result.setLabelPosition("none");
            return result;
        }

        private UIComponent createRtbody(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspInputRichText result = new XspInputRichText();
            String sourceId = "rtBody/@value";
            String valueExpr = "#{dominoDoc.Body}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            result.setStyleClass("mblThreadRichText");
            setId(result, "rtBody");
            return result;
        }

        private UIComponent createPanel1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            // loaded=??
            String loadedBnd = "#{javascript:!isMobile()}";
            String sourceId = "panel1/@loaded";
            String loaded = evaluator.evaluateAsString(null, loadedBnd, sourceId, boolean.class);
            if ( null != loaded && loaded.length() > 0 &&
                    ! Boolean.parseBoolean(loaded) ) {
                return null;
            } // else loaded was true
            UIPanelEx result = new UIPanelEx();
            result.setStyleClass("attachFilePanel");
            setId(result, "panel1");
            return result;
        }

        private UIComponent createLink1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspOutputLink result = new XspOutputLink();
            String sourceId = "link1/@style";
            String styleExpr = "float: #{javascript: context.isDirectionRTL() ? \'right\' : \'left\'};";
            ValueBinding style = evaluator.createValueBinding(result, styleExpr, sourceId,String.class);
            result.setValueBinding("style", style);
            result.setEscape(true);
            result.setRole("button");
            result.setStyleClass("attachFileLink");
            result.setTitle("expand area to attach a file to document");
            setId(result, "link1");
            result.setText(" Attach File");
            return result;
        }

        private UIComponent createEventhandler4(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspEventHandler result = new XspEventHandler();
            result.setSubmit(false);
            result.setEvent("onclick");
            String sourceId = "eventHandler4/xp:this.script[1]/text()";
            MethodBinding script = evaluator.createMethodBinding(result,
                    "var fileContainer = document.getElementById(\"#{id:fileContainer}\");\n\t\t\t\t\tvar upload = document.getElementById(\"#{id:fileUpload}\");\n\t\t\t\t\tif(null != fileContainer)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar displayStyle = fileContainer.style.height;\n\t\t\t\t\t\tif (!displayStyle || displayStyle == \"0px\")\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfileContainer.style.height = \'50px\';\n\t\t\t\t\t\t\tfileContainer.style.width = \'250px\';\n\t\t\t\t\t\t\tupload.style.height = \'25px\';\n\t\t\t\t\t\t\tupload.style.width = \'200px\';\n\t\t\t\t\t\t} \n\t\t\t\t\t\telse \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfileContainer.style.height = \'0px\';\n\t\t\t\t\t\t\tfileContainer.style.width = \'0px\';\n\t\t\t\t\t\t\tupload.style.height = \'0px\';\n\t\t\t\t\t\t\tupload.style.width = \'0px\';\n\t\t\t\t\t\t}\n\t\t\t\t\t}",
                    null,null, sourceId);
            result.setScript(script);
            setId(result, "eventHandler4");
            return result;
        }

        private UIComponent createImage2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspGraphicImage result = new XspGraphicImage();
            result.setAlt("Add Attachment");
            setId(result, "image2");
            result.setUrl("/xpAttachment.gif");
            return result;
        }

        private UIComponent createDiv(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspDiv result = new XspDiv();
            String sourceId = "panel1/xp:div[1]/@style";
            String styleExpr = "float: #{javascript: context.isDirectionRTL() ? \'left\' : \'right\'};";
            ValueBinding style = evaluator.createValueBinding(result, styleExpr, sourceId,String.class);
            result.setValueBinding("style", style);
            result.setDir("ltr");
            return result;
        }

        private UIComponent createFiledownload1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspFileDownload result = new XspFileDownload();
            String sourceId = "fileDownload1/@value";
            String valueExpr = "#{dominoDoc.Body}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            result.setDisplayLastModified(false);
            result.setAllowDelete(true);
            result.setStyleClass("mainTopicDownload");
            result.setRows(30);
            setId(result, "fileDownload1");
            result.setHideWhen(true);
            return result;
        }

        private UIComponent createFilecontainer(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            // loaded=??
            String loadedBnd = "#{javascript:!isMobile()}";
            String sourceId = "fileContainer/@loaded";
            String loaded = evaluator.evaluateAsString(null, loadedBnd, sourceId, boolean.class);
            if ( null != loaded && loaded.length() > 0 &&
                    ! Boolean.parseBoolean(loaded) ) {
                return null;
            } // else loaded was true
            UIPanelEx result = new UIPanelEx();
            result.setStyle("height:0px; width:0px;");
            setId(result, "fileContainer");
            return result;
        }

        private UIComponent createBr(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspLineBreak result = new XspLineBreak();
            return result;
        }

        private UIComponent createFileupload(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspFileUpload result = new XspFileUpload();
            String sourceId = "fileUpload/@value";
            String valueExpr = "#{dominoDoc.Body}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            result.setStyle("margin-top:5px; height:0px; width:0px;");
            result.setRole("upload");
            setId(result, "fileUpload");
            return result;
        }

        private UIComponent createEventHandler(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspEventHandler result = new XspEventHandler();
            String sourceId = "fileUpload/xp:eventHandler[1]/xp:this.action[1]/text()";
            MethodBinding action = evaluator.createMethodBinding(result,
                    "#{javascript:// kick off round-trip...}",
                    null,null, sourceId);
            result.setAction(action);
            result.setSubmit(true);
            result.setEvent("onchange");
            result.setRefreshMode("complete");
            return result;
        }

        private UIComponent createBr2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspLineBreak result = new XspLineBreak();
            return result;
        }

        private UIComponent createBr3(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspLineBreak result = new XspLineBreak();
            return result;
        }

        private UIComponent createPanel16(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIPanelEx result = new UIPanelEx();
            result.setStyleClass("xlFormFooterContainer");
            setId(result, "panel16");
            return result;
        }

        private UIComponent createButton2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspCommandButton result = new XspCommandButton();
            result.setValue("Save");
            result.setRole("submit");
            result.setStyleClass("lotusFormButton");
            result.setTitle("save button for new document form");
            setId(result, "button2");
            return result;
        }

        private UIComponent createEventhandler2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspEventHandler result = new XspEventHandler();
            result.setExecMode("partial");
            ActionGroup action = new ActionGroup();
            action.setComponent(result);
            SaveAction actions = new SaveAction();
            actions.setComponent(result);
            String sourceId = "eventHandler2/xp:this.action[1]/xp:actionGroup[1]/xp:save[1]/@name";
            String nameExpr = "#{javascript:compositeData.gotoPage}";
            ValueBinding name = evaluator.createValueBinding(result, nameExpr, sourceId,String.class);
            actions.setValueBinding("name", name);
            actions.setSourceReferenceId("eventHandler2/xp:this.action[1]/xp:actionGroup[1]/xp:save[1]");
            action.addAction(actions);
            action.setSourceReferenceId("eventHandler2/xp:this.action[1]/xp:actionGroup[1]");
            result.setAction(action);
            result.setSubmit(true);
            result.setEvent("onclick");
            setId(result, "eventHandler2");
            result.setExecId("mainTopic");
            result.setRefreshMode("complete");
            return result;
        }

        private UIComponent createLinkcancel(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspOutputLink result = new XspOutputLink();
            String sourceId = "linkCancel/@value";
            String valueExpr = "#{javascript:compositeData.gotoPage}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            Map<String,Object> attrs = getAttributes(result);
            attrs.put("themeId", "Link.action");
            result.setRole("button");
            setId(result, "linkCancel");
            result.setText("Cancel");
            return result;
        }

    }
}
